package com.shanzmoo.core.util;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import cn.hutool.extra.spring.SpringUtil;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

/**
 * 邮件工具类
 * @author fs
 */
@UtilityClass
@Slf4j
public class MailUtils {
    public void send(String to,String title,String content){
        try{
            MailAccount ma = SpringUtil.getBean("mailAccount", MailAccount.class);
            MailUtil.send(ma,to,title,content,false);
        }catch (Exception e){
            log.error("邮件发送失败:{}",e);
        }
    }
    public void send(String[] tos,String title,String content){
        for(String to:tos){
            send(to,title,content);
        }
    }
}
